
import javax.swing.*;

public class example3_3 {
    public static void main(String[] args) {
        int sum = mysum(100);
        JOptionPane.showMessageDialog(null, "1+2+3+4+5+..100=" + sum);
        System.exit(0);
    }

    static int mysum(int n) {
        int i, s = 0;
        for (i = 1; i <= n; i++)
            s = s + i;
        return s;
    }
}

// 教材58 3-3，实现1加到100
